find_package(PkgConfig)
pkg_check_modules(PC_RLOTTIE rlottie)

find_path(RLOTTIE_INCLUDE_DIRS
    NAMES rlottie.h
    HINTS ${PC_RLOTTIE_INCLUDEDIR}
    ${PC_RLOTTIE_INCLUDE_DIRS}
)

find_library(RLOTTIE_LIBRARIES
    NAMES rlottie
    HINTS ${PC_RLOTTIE_LIBDIR}
    ${PC_RLOTTIE_LIBRARY_DIRS}
)

if(RLOTTIE_INCLUDE_DIRS AND RLOTTIE_LIBRARIES)
    set(RLOTTIE_FOUND TRUE)
    set(RLOTTIE_LIBRARY ${RLOTTIE_LIBRARIES})
    set(RLOTTIE_INCLUDE_DIR ${RLOTTIE_INCLUDE_DIRS})
    set(RLOTTIE_VERSION ${PC_RLOTTIE_VERSION})
    include(FindPackageHandleStandardArgs)
    FIND_PACKAGE_HANDLE_STANDARD_ARGS(RLOTTIE FOUND_VAR RLOTTIE_FOUND VERSION_VAR RLOTTIE_VERSION
	    REQUIRED_VARS RLOTTIE_INCLUDE_DIRS RLOTTIE_INCLUDE_DIR RLOTTIE_LIBRARIES RLOTTIE_LIBRARY)

    mark_as_advanced(RLOTTIE_LIBRARIES RLOTTIE_LIBRARY RLOTTIE_INCLUDE_DIRS RLOTTIE_INCLUDE_DIR RLOTTIE_FOUND RLOTTIE_VERSION)

    if(NOT TARGET rlottie::rlottie)
        add_library(rlottie::rlottie UNKNOWN IMPORTED)
        set_target_properties(rlottie::rlottie PROPERTIES
          INTERFACE_COMPILE_DEFINITIONS "${_RLOTTIE_COMPILE_DEFINITIONS}"
          INTERFACE_INCLUDE_DIRECTORIES "${RLOTTIE_INCLUDE_DIRS}"
          #INTERFACE_LINK_LIBRARIES pthread
          )

        if(EXISTS "${RLOTTIE_LIBRARY}")
          set_target_properties(rlottie::rlottie PROPERTIES
            IMPORTED_LINK_INTERFACE_LANGUAGES "C"
            IMPORTED_LOCATION "${RLOTTIE_LIBRARY}")
        endif()
    endif()
endif()

